#DEBUG = -DDEBUG -DDEBUGSCREEN
#DEBUG = -DDEBUG -DDEBUG2
DEBUG = -DDEBUG 

LOG = -DLOGFACILITY=LOG_LOCAL7

NETWORK = -DUSE_NETWORK 

MODULE = -DPLATFORM

# these components settings need to be moved into a platform config file & struct
COMPONENTS  = -DENGINEERING_SIMULATE_BATTERY
COMPONENTS += -DENGINEERING_USE_GPSD
COMPONENTS += -DENGINEERING_USE_COMPASS
COMPONENTS += -DENGINEERING_USE_SD84
#COMPONENTS += -DENGINEERING_USE_SONDE
COMPONENTS += -DSCIENCE_USE_GOTEMP_AIRTEMP
COMPONENTS += -DSCIENCE_SIMULATE_WATERTEMP
COMPONENTS += -DNEEDCMDFILETHREAD

GNOMEINC  = -I/usr/include/libgnome-2.0
GNOMEINC += -I/usr/include/glib-2.0
GNOMEINC += -I/usr/lib/glib-2.0/include
GNOMEINC += -I/usr/include/libbonobo-2.0

INCDIR  = ${GNOMEINC} 
INCDIR += -I.
INCDIR += -I../common
INCDIR += -Ilib
INCDIR += -Iengineering
INCDIR += -Iengineering/simulate
INCDIR += -Iengineering/hardware
INCDIR += -Ienvironment
INCDIR += -Ienvironment/simulate
INCDIR += -Ienvironment/hardware

CFLAGS = -Wall ${DEBUG} ${LOG} ${NETWORK} ${COMPONENTS} 

CC = gcc ${CFLAGS} ${INCDIR}
CPP = g++ ${CFLAGS} ${INCDIR}

GNOMELIBS = -lgnome-2

GPSLIBS = -lgps

ENGOBJS  = controls.o
ENGOBJS += gpsd.o
ENGOBJS += compass.o
ENGOBJS += cssl.o
ENGOBJS += sd84.o
ENGOBJS += simulate_battery.o
ENGOBJS += simulate_position.o
ENGOBJS += sonde.o
#ENGOBJS += simulate_attitude.o
#ENGOBJS += simulate_speed.o
#ENGOBJS += simulate_heading.o

ENVOBJS  = science_main.o
ENVOBJS += gotemp.o
ENVOBJS += simulate_fluorometer.o
ENVOBJS += simulate_wind.o
ENVOBJS += simulate_current.o
ENVOBJS += simulate_airpressure.o
ENVOBJS += simulate_airtemp.o
ENVOBJS += simulate_watertemp.o
ENVOBJS += simulate_humidity.o

BASEOBJS  = command.o
BASEOBJS += commandfile.o
BASEOBJS += readconfigfile.o
BASEOBJS += delay.o
BASEOBJS += config.o
BASEOBJS += waypoints.o
BASEOBJS += logfile.o
BASEOBJS += diff.o
BASEOBJS += status.o
BASEOBJS += telemfile.o
BASEOBJS += socket.o

#SIMOBJS  = simulator.o
#SIMOBJS += ${BASEOBJS}
#SIMOBJS += ${ENGOBJS}
#SIMOBJS += ${ENVOBJS}

PLATOBJS  = platform.o
PLATOBJS += platformstatus.o
PLATOBJS += engineering_main.o
PLATOBJS += controller.o
PLATOBJS += trajplan.o
PLATOBJS += ${BASEOBJS}
PLATOBJS += ${ENGOBJS}
PLATOBJS += ${ENVOBJS}

CALOBJS  = calibrate.o
CALOBJS += delay.o
CALOBJS += waypoints.o
CALOBJS += status.o
CALOBJS += compass.o
CALOBJS += cssl.o
CALOBJS += sd84.o


default: all 

all: boat 

unused :
	rm -f *.o

clean : unused
	rm -f *.exe *.a *.stackdump simulator platform

distclean: clean
	rm -f *.log data/*.txt 
			
platform: boat

boat : ${PLATOBJS}
	${CPP} -o platform ${PLATOBJS} ${LIBDIR} ${IRCLIBS} ${GNOMELIBS} ${GPSLIBS}

calibrate : ${CALOBJS}
	${CPP} -o calibrate ${CALOBJS} ${LIBDIR} ${IRCLIBS} ${GNOMELIBS} ${GPSLIBS}

#sim : ${SIMOBJS}  
#	${CPP} -o simulator ${SIMOBJS} ${LIBDIR} ${IRCLIBS} ${GNOMELIBS}


# object files from this directory

%.o : %.c 
	${CC} -c $<		
	
	
# object files from engineering subdirectory	

%.o : engineering/%.c 
	${CC} -c $<		

%.o : engineering/simulate/%.c 
	${CC} -c $<		

%.o : engineering/hardware/%.c 
	${CC} -c $<		

#object files from environment subdirectory

%.o : environment/%.c 
	${CC} -c $<		

simulate_fluorometer.o : environment/simulate/simulate_fluorometer.cpp 
	${CPP} -c $<		

%.o : environment/simulate/%.c 
	${CC} -c $<		

%.o : environment/hardware/%.c 
	${CC} -c $<		

# object files from SSA common directory

%.o : ../common/%.c ../common/%.h
	${CC} -c $<		

# object files from SSA lib directory

%.o : lib/%.c 
	${CC} -c $<		
